﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SimoBotRewritten
{
    public partial class frmConnect : Form
    {
        public frmMain MainForm;
        public frmConnect(frmMain FormMain)
        {
            InitializeComponent();
            MainForm = FormMain;
        }

        private bool IsNumber(string str)
        {
            try
            {
                Convert.ToInt32(str);
            }
            catch
            {
                return false;
            }
            return true;
        }

        private void btnClose_Click(object sender, EventArgs e)
        {

 
            try
            {
                int TestPort = Convert.ToInt32(txtPort.Text);
            }

            catch (FormatException f)
            {
                txtPort.Text = "Plz numb3rs only";
            }

            catch (OverflowException f)
            {
                txtPort.Text = "Short number kthx";
            }
             

            if (IsNumber(txtPort.Text))
            {
                string Server = txtServer.Text;
                string Channel = txtChannel.Text;
                string Nick = txtNick.Text;
                string Port = txtPort.Text;

                MainForm.SetConnectInfo(Server, Port, Channel, Nick);

                this.Close();
            }
        }
    }
}
